package thread;

import java.util.ArrayList;
import java.util.Collection;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

public class ThreadServlet extends HttpServlet {

	private static final long serialVersionUID = 1L;
	
	private Collection<Thread> threads;

	public void init(ServletConfig config) throws ServletException {
		threads = new ArrayList<Thread>();
		threads.add(new PartidaThread());
		for (Thread thread : threads) {
			thread.start();
		}
	}
	
	@Override
	public void destroy() {
		for (Thread thread : threads) {
			try {
				thread.interrupt();
			} catch (Exception e) {
				/* Vazio */
			}
		}
	}

}
